<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>商城快递配置</title>
    {template 'stourtravel/public/public_min_js'}
    {php echo Common::getCss('style.css,base.css,base2.css,base_new.css,../js/jqueryui/jquery-ui.min.css'); }
    {php echo Common::getScript("choose.js,product_add.js,jqueryui/jquery-ui.min.js"); }
    <style>
        .product-add-div{
            float: inherit;
        }
    </style>
</head>
<body>
<table class="content-tab">
    <tr>
        <td width="119px" class="content-lt-td"  valign="top">
            {template 'stourtravel/public/leftnav'}
            <!--右侧内容区-->
        </td>
        <td valign="top" class="content-rt-td">

            <form id="configfrm">
                <div class="w-set-con">
                    <div class="cfg-header-bar">
                        <a href="javascript:;" class="fr btn btn-primary radius mt-6 mr-10" onclick="window.location.reload()">刷新</a>
                    </div>
                    <div class="w-set-nr">
                        <ul class="info-item-block">
                            <li>
                                <span class="item-hd">快递状态：</span>
                                <div class="item-bd">
                                    <label class="radio-label">
                                        <input type="radio" name="cfg_malls_express_open" value="1" {if $config['cfg_malls_express_open']==1}checked{/if}>开启
                                    </label>
                                    <label class="radio-label ml-20">
                                        <input type="radio" name="cfg_malls_express_open" value="0" {if $config['cfg_malls_express_open']==0}checked{/if}>关闭
                                    </label>
                                    <span class="item-text pl-20 c-999">*当前快递使用快递100接口，需要自主申请。开启快递后，用户在预订产品后可以在填写相关快递信息，并进行查询物流信息。</span>
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">Customer：</span>
                                <div class="item-bd">
                                    <input type="text" name="cfg_malls_express_customer" id="cfg_malls_express_customer" class="input-text w200" value="{$config['cfg_malls_express_customer']}">
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">快递100Key：</span>
                                <div class="item-bd">
                                    <input type="text" name="cfg_malls_express_key" id="cfg_malls_express_key" class="input-text w200" value="{$config['cfg_malls_express_key']}">
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">快递选择：</span>
                                <div class="item-bd product-add-div">
                                    <a href="javascript:;" class="fl btn btn-primary radius size-S mt-3"  onclick="dialog_company(this,'.company-sel')"  title="选择">选择</a>
                                    <div class="fl save-value-div ml-10 company-sel w700">
                                        {loop $company_list $k $v}
                                        <span class="item-text mb-5"><s onclick="$(this).parent('span').remove()"></s>{$v['company_name']}<input type="hidden" name="company[]" value="{$v['id']}"></span>
                                        {/loop}
                                    </div>
                                </div>
                            </li>
                        </ul>
                        <div class="clear clearfix mt-5">
                            <a class="btn btn-primary size-L radius ml-115" href="javascript:;" id="btn_save">保存</a>
                            <input type="hidden" name="webid" id="webid" value="0">
                        </div>
                    </div>
                </div>
            </form>
        </td>
    </tr>
</table>
</body>
<script type="text/javascript">
    $(document).ready(function(){
        //配置信息保存
        $("#btn_save").click(function(){
            var is_open = $("input[name='cfg_malls_express_open']:checked").val();
            var express_key = $("input[name='cfg_malls_express_key']").val();
            var express_customer = $("input[name='cfg_malls_express_customer']").val();
            var data_arr = $(".company-sel").find("input");
            var new_arr = [];
            $.each(data_arr,function(index,item){
                new_arr.push($(this).val());
            });
            var ids = new_arr.join(',');

            var postData = {is_open:is_open,express_key:express_key,express_customer:express_customer,ids:ids};
            $.post(SITEURL+'express/save_express_config',postData,function(res){
                ST.Util.showMsg('保存成功!', '4', 2000);
            },'json')
        });
    });

    // 选择快递公司
    function dialog_company(obj,selector)
    {
        var data_arr = $(".company-sel").find("input");
        var new_arr = [];
        $.each(data_arr,function(index,item){
            new_arr.push($(this).val());
        });
        var ids = new_arr.join(',');
        CHOOSE.setSome("选择快递公司",{loadWindow:window,loadCallback:setExpressCompany,maxHeight:400},SITEURL+'express/dialog_express?ids='+ids,1);
    }

    function setExpressCompany(data,bool)
    {
        var html = '';
        $.each(data.data,function(index,item){
            html += '<span class="item-text mb-5">' +
                '<s onclick="$(this).parent(\'span\').remove()"></s>' + item['name'] +
                '<input type="hidden" name="company[]" value="'+item['id']+'">' +
                '</span>'
        });

        $(".company-sel").html(html);
    }
</script>
</html>
